<?php use_javascript('datapiker.js');?>
<?php use_stylesheet('datepicker.css');?>
<div class="title"><?php echo __('Список оплат')?></div>

<?php $form = new MailboxFormFilter(); ?>
<?php 

 $form->setDefaults(array(
    	'from_id' => sfContext::getInstance()->getRequest()->getParameter('mailbox_filters[from_id]'),
    	'to_id' => sfContext::getInstance()->getRequest()->getParameter('mailbox_filters[to_id]'),
        'date_from' => sfContext::getInstance()->getRequest()->getParameter('mailbox_filters[date_from]'),
        'date_to' => sfContext::getInstance()->getRequest()->getParameter('mailbox_filters[date_to]'),
         'alert' => sfContext::getInstance()->getRequest()->getParameter('mailbox_filters[alert]'),
  	
    ));

?>

<form action="<?php echo url_for('checkmail/index')?>" method="GET">
<table>
<tr>
<td><?php echo $form['from_id']->render()?></td>
<td><?php echo $form['to_id']->render()?></td>
<td>
    с
    <?php echo $form['date_from']->render()?>
    по
    <?php echo $form['date_to']->render()?>
</td>
<td><?php echo $form['alert']->render()?></td>

<td><input type="submit" value="<?php echo __('Фильтр')?>"></td>
</tr>
</table>
</form>

<?php if ($mail->getResults()): ?>
	<table class="table1" width="100%">
	         <tr>
	         <th><?php echo __('От кого')?></th>
			<th><?php echo __('Кому')?></th>
			<th><?php echo __('Содержимое')?></th>
			<th><?php echo __('Дата')?></th>
			<th><?php echo __('Действия')?></th>
			</tr>
		 <?php foreach ($mail->getResults() as $p): ?>
		 <tr>
		 <td><?php echo $p->getsfGuardUserRelatedByFromId() ?></td>
		 <td><?php echo $p->getsfGuardUserRelatedByToId() ?></td>
		 <td><?php echo $p->getBody()?></td>
		 <td><?php echo format_date($p->getCreatedAt(),'d')?></td>
		 
		 <td><?php echo link_to(__('Редактировать'),'checkmail/edit'.$sf_request->params2str(array('id'=>$p->getId())))?> <br />
		 <?php echo link_to(__('Удалить'),$sf_params->get('module').'/'.$sf_params->get('action').$sf_request->params2str(array('id'=>$p->getId(),'del'=>true)),array('style'=>'color: red','confirm'=>__('Вы уверены?')))?>
		 </td>
		 
		 </tr>
		 <?php endforeach; ?>
	</table>
	<?php include_partial('global/common/pager', array('pager'=>$mail)) ?>

<?php else: ?>

 
 <?php echo __('Результатов не найдено')?>
 
<?php endif ?>


      <script type="text/javascript">
  $(document).ready(function(){
    // ---- Календарь -----
    $('#mailbox_filters_date_from').attachDatepicker();
    $('#mailbox_filters_date_to').attachDatepicker();
    // ---- Календарь -----
  });
  </script>